package Exception.demo1;

import java.io.UnsupportedEncodingException;
import java.util.Arrays;

public class Test {
    public static void main(String[] args) {
        byte[] bs = toGBK("中文");
        System.out.println(Arrays.toString(bs));
    }

    private static byte[] toGBK(String s) {
        try {
            return s.getBytes("GBK");
        } catch (UnsupportedEncodingException e) {
            System.out.println(e); // 打印异常信息
            return s.getBytes(); // 尝试使用用默认编码
        }finally {
            System.out.println(111);
        }
    }
}
